<?php
require_once('lib/db_connection.php');
$query_veh = "SELECT * FROM dts_veh_tbl WHERE company_id='".$_SESSION['company_id']."'";
$result_veh = mysql_query($query_veh) or die("SELECT VEHICLES ".mysql_error());
?>
<html>
<head>
<script type='text/javascript' src='js/select_helper.js'></script>
<!--<link rel="stylesheet" type="text/css" href="css/grid.css" />-->
</head>

<body onLoad='checkIt()' style="background-color:black">
<p style='color:white;font-size:12px;' id='tot_expected'></p>
<hr />
<table border='1' style='width:100%;margin-left:0%;margin-right:0%;'>
<tr>
  <th style='width:50%;color:white;'>PLATE</th>
  <th style='width:50%;color:white;'>HAULER</th>
</tr>
 <?php
 $str_ids = "";
 $tot_exp = 0;
 while($row_veh = mysql_fetch_array($result_veh))
 {
 $query_queue = "SELECT * FROM queue_tbl WHERE plate_id='".$row_veh['vehicle_id']."' ORDER BY autoid DESC LIMIT 0,1";
 $result_count = mysql_query($query_queue) or die("CHECK QUEUE ".mysql_error());
 $count = mysql_num_rows($result_count);
 if($count!=0)
 {
 $result_queue = mysql_query($query_queue) or die("SELECT QUEUE ".mysql_error());
 $row_queue = mysql_fetch_array($result_queue );
 if($row_queue['status']=='intransit')
 {
 $tot_exp++;
?>
 <tr>
  <td style='font-size:12px;width:50px;color:white;'><?php echo $row_veh["veh_num"]?></td>
  <td style='font-size:12px;width:50px;color:white;'><?php echo $row_queue["hauler_name"]?></td>
 </tr>
<?php
 }
 }
 }
 echo "<script type='text/javascript'>
 document.getElementById('tot_expected').innerHTML = 'TOTAL EXPECTED TRUCK: '+'".$tot_exp."';
 </script>";
?>
</table>
</body>
</html>